;
const user_reset_ops = {
    init () {
        this.eventBind();
    },
    eventBind () {
        $("#save").click(function() {
            let btn_target = $(this);
            if (btn_target.hasClass('disabled')) {
                common_ops.alert("正在处理提交中")
                return;
            }
            const old_password = $("#old_password").val();
            const new_password = $("#new_password").val();

            if (!old_password) {
                common_ops.tip("请输入符合规范的原密码！！")
                return false;
            }
           if (!new_password && new_password.length < 6) {
                common_ops.tip("请输入不少于6位的新密码！！")
                return false;
           }

            btn_target.addClass("disabled")
            const data = {
                old_password,
                new_password
            }
            $.ajax({
                url: common_ops.buildUrl("/user/reset-pwd"),
                type: 'POST',
                data: data,
                dataType: 'json',
                success: function (res) {
                    btn_target.removeClass("disabled");
                    let callback = null;
                    if (res.code === 200) {
                        callback = function () {
                            window.location.href = window.location.href;
                        }
                    }
                    common_ops.alert(res.msg, callback);
                }
            })
        })
    }
}

$(document).ready(function () {
    user_reset_ops.init()
})